package com.ltg.urban.domain.sys.controller;

import com.ltg.framework.annotation.DescribePage4Swagger;
import com.ltg.framework.util.http.PageInfo;
import com.ltg.framework.util.http.PageRequest;
import com.ltg.framework.util.http.Result;
import com.ltg.urban.domain.sys.data.request.ModifyMenuReq;
import com.ltg.urban.domain.sys.entity.SysMenu;
import com.ltg.urban.domain.sys.service.SysMenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p> ClassName: SysMenuController </p>
 * <p> Package: com.ltg.urban.domain.user.controller </p>
 * <p> Description: </p>
 * <p></p>
 *
 * @Author: LTG
 * @Create: 2023/2/24 - 9:24
 * @Version: v1.0
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/menu")
@Tag(name = "菜单(权限)模块:暂时不用")
public class SysMenuController {

    /**
     * 3.权限模块:每个系统角色都可以拥有对应操作系统信息的增删改查的权限。一个用户可以设置一个角色，一个角色可以拥有多个权限。
     */


    private final SysMenuService sysMenuService;

    @GetMapping("/list")
    @Operation(summary = "分页查询:OK")
    @DescribePage4Swagger
    public PageInfo<SysMenu> query(HttpServletRequest httpServletRequest) {
        return sysMenuService.pageLis(PageRequest.buildFromRequest(httpServletRequest));
    }

    @PostMapping("/create")
    @Operation(summary = "创建菜单:OK")
    public Result<SysMenu> create(@RequestBody ModifyMenuReq req) {
        return sysMenuService.create(req);
    }

    @PutMapping("/modify/{menuId}")
    @Operation(summary = "修改:OK")
    public Result<SysMenu> modify(@PathVariable String menuId, @RequestBody ModifyMenuReq req) {
        return sysMenuService.modify(menuId, req);
    }

    @DeleteMapping("/delete/{menuId}")
    @Operation(summary = "删除:OK")
    public Result<Void> delete(@PathVariable String menuId) {
        sysMenuService.removeById(menuId);
        return Result.success();
    }

}
